public class FindPoisonedDuration {
    //提莫攻击
    public int code(int[] timeSeries, int d) {
        int ret = 0;
        for (int i = 0; i < timeSeries.length - 1; i++){
            if (timeSeries[i + 1] - timeSeries[i] > d){
                ret += d;
            }else{
                ret += (timeSeries[i + 1] - timeSeries[i]);
            }
        }

        return ret + d;
    }
}
